﻿using Common;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading;

namespace MonitorService
{
    class Program
    {
        private static Mutex _mutex;
        static void Main(string[] args)
        {
            RedisHelper redis = new RedisHelper();
            //redis.StringSet("test", new Student{ ID = 1, Name = "三歪" });
            //Student data =redis.StringGet<Student>("test");
            _mutex = new Mutex(true, "Redis.Queue");
            if (_mutex.WaitOne())
            {
                while (true)
                {
                    RedisQueue<Student> queue = RedisMQ.Consume<Student>();
                    if (queue == null)
                    {
                        Thread.Sleep(10000);
                        continue;

                    }
                    Console.WriteLine(queue.Message.Name);
                }

            }

            Console.ReadLine();
        }
    }
}
